#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{int d,v,a;} a[100005];
struct range{int l,r;} mark[100005];
bool cmp(range x,range y)
{
    if(x.r==y.r)
        return x.l<y.l;
    return x.r<y.r;
}
int p[100005];
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    int T;
    cin>>T;
    while(T--)
    {
        int n,m,L,v;
        cin>>n>>m>>L>>v;
        for(int i=1;i<=n;i++)
            cin>>a[i].d>>a[i].v>>a[i].a;
        for(int i=1;i<=m;i++)
            cin>>p[i];
        int ans1=0,tot=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i].d>p[m])
                continue;
            int np=lower_bound(p+1,p+m+1,a[i].d)-p;
            if(a[i].a==0){
                ans1+=(a[i].v>v);
                if(a[i].v>v)
                    mark[++tot]={np,m};
            }
            else if(a[i].a>0){
                if((a[i].v*a[i].v+2*a[i].a*(p[m]-a[i].d)) > v*v)
                {
                    ans1++;
                    int l=np,r=m,res=m;
                    while(l<=r)
                    {
                        int mid=(l+r)>>1;
                        if((a[i].v*a[i].v+2*a[i].a*(p[mid]-a[i].d)) > v*v)
                            res=mid,r=mid-1;
                        else
                            l=mid+1;
                    }
                    mark[++tot]={res,m};
                }
            }
            else{
                if((a[i].v*a[i].v+2*a[i].a*(p[np]-a[i].d)) > v*v)
                {
                    ans1++;
                    int l=np,r=m,res=m;
                    while(l<=r)
                    {
                        int mid=(l+r)>>1;
                        if((a[i].v*a[i].v+2*a[i].a*(p[mid]-a[i].d)) > v*v)
                            res=mid,l=mid+1;
                        else
                            r=mid-1;
                    }
                    mark[++tot]={np,res};
                }

            }
        }
        cout<<ans1<<' ';
        sort(mark+1,mark+tot+1,cmp);
        int lmk=-1,ans2=0;
        for(int i=1;i<=tot;i++)
        {
            if(lmk>=mark[i].l)
                continue;
            ans2++,lmk=mark[i].r;
        }
        cout<<m-ans2<<'\n';
    }
    return 0;
}
